Next | Prev | Up | Top | Contents | Index

Allocating IRQs and Channels

Before a kernel-level driver can field EISA interrupts, it must associate a handler with one of the IRQ levels. In order to perform DMA, the driver must allocate one of the DMA channels. The functions used for these purposes are summarized inTable 17-2

Functions for IRQ and Channel Allocation
FunctionHeader FilesCan SleepPurpose
eisa_dmachan_alloc()eisa.h & types.hNAllocate DMA channel.
eisa_ivec_alloc() eisa.h & types.hNAllocate IRQ and set triggering.
eisa_ivec_set()eisa.h & types.hNAssociate handler to IRQ.

Note: There are no reference pages for the functions in Table 17-2.


Allocating and Programming an IRQ

The function eisa_ivec_alloc() allocates an available IRQ number from a set of acceptable numbers. Its prototype is

int eisa_ivec_alloc(uint_t adap,ushort_t mask,uchar_t trig);

The arguments are as follows:

adap The adapter number, always 0 in current systems.
mask A 16-bit mask containing a 1-bit for each IRQ level that is acceptable for this device. (For available IRQ levels, see "EISA Interrupts".)
trig The triggering method used by the card, either EISA_EDGE_IRQ or EISA_LEVEL_IRQ from sys/eisa.h.

ISA cards are usually hard-wired or jumpered to a particular IRQ, so that the mask argument contains a single bit. Some EISA cards can be programmed dynamically to use a selected IRQ; in that case mask contains a 1-bit for each IRQ the card can be programmed to use.

The function attempts to allocate an IRQ from the mask set that is not in use by any card. If all acceptable levels are in use, it allocates an IRQ that is already in use with the requested kind of triggering. In either case, it returns the number of the IRQ to be used.

In the event that all the IRQs requested are already in use with a conflicting type of triggering, the function returns -1.

After allocating an IRQ, the device driver programs the card (using PIO) to interrupt on that line.

The function eisa_ivec_set() associates a function in the device driver with an IRQ number. Its prototype is

int eisa_ivec_set(uint_t adap, int irq, void (*e_intr)(long), long e_arg)

The parameters are as follows:

adap The adapter number, always 0 in current systems.
irq The IRQ level to be monitored.
e_intr The address of the interrupt handling function to call.
e_arg An argument to pass to the function when called.

When more than one device is allocated the same IRQ, the kernel calls all the interrupt functions associated with that IRQ. This means that an interrupt function must always verify, by testing device registers, that the interrupt was caused by its device.

The first call to eisa_ivec_set() for a given IRQ enables interrupts from that IRQ. Prior to the call, interrupts from that IRQ are ignored.

Note: If you are working with both the VME and EISA interfaces, it is worth noting that the number and type of arguments of eisa_ivec_set() differ from those of vme_ivec_set().

Note: There is no way to retract the association of an interrupt function with an IRQ. This means that if an EISA driver handles interrupts and is loadable, it must not support the pfxunload() entry point. An interrupt arriving after the driver had been unloaded would panic the system.


Allocating a DMA Channel

The function eisa_dmachan_alloc() allocates one of the seven available DMA channels (channel 4 is reserved by the hardware) from a set of acceptable channels. The function's prototype is

int eisa_dmachan_alloc(uint_t adap, uchar_t dma_mask)

The arguments are as follows:

adap The adapter number, always 0 in current systems.
dma_mask An 8-bit mask containing 1-bits for the DMA channels that can be used by this device.

The function allocates the channel in the requested set that is in use by the fewest devices. It is possible for a single channel to be requested by multiple devices. However, if the device can use any of several channels, it is likely that the device will be the only one using the channel whose number is returned. After allocating a channel number, the device driver programs the device to use that channel, if necessary.


Next | Prev | Up | Top | Contents | Index